'use strict'

class deluser {
    constructor() {
        this.param = '/:id'
    }
    //创建资源
    async get(c) {
        //根据建议id删除建议
        var user_id = c.param.id;
        try {
            let sqltext1 = `DELETE FROM users WHERE user_id = ${user_id}`;
            var r1 = await c.service.psql.query(sqltext1);
            var table1 = "user_" + user_id + "_pay_sti";
            var table2 = "user_" + user_id + "_pay_tem";
            var table3 = "user_" + user_id + "_techo";
            let sqltext2 = `DROP TABLE ${table1}`;
            var r2 = await c.service.psql.query(sqltext2);
            let sqltext3 = `DROP TABLE ${table2}`;
            var r3 = await c.service.psql.query(sqltext3);
            let sqltext4 = `DROP TABLE ${table3}`;
            var r4 = await c.service.psql.query(sqltext4);
            c.send("success");
            return
        }
        catch (err) {
            return c.status(500).send('error');
        }
    }
}

module.exports = deluser